package com.cadre.web.controller.officer;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cadre.common.utils.R;
import com.cadre.system.domain.officer.TD_SearchDictionary;
import com.cadre.system.service.DPersontagService;
import com.cadre.system.service.SearchDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Api(value = "智搜输入框处理", tags = {"A-智搜输入框处理"})
@RequestMapping({"/SearchInput/"})
@RestController
/* loaded from: SearchDictionaryController.class */
public class SearchDictionaryController {
    @Autowired
    private SearchDictionaryService sds;
    @Autowired
    private DPersontagService dPersontagService;

    @GetMapping({"/taglist/{value}"})
    @ApiOperation("获取输入搜索结果")
    public R info(@PathVariable("value") String value) {
        return R.ok().put("list", (Object) this.sds.selectListByInput(value));
    }

    @GetMapping({"/infoList"})
    @ApiOperation("获取输入搜索结果")
    public R infoList() {
        return R.ok().put("list", (Object) this.sds.getBaseMapper().selectList(new LambdaQueryWrapper<>()));
    }

    @GetMapping({"/list/{value}"})
    @ApiOperation("搜索按钮处理")
    public R list(@PathVariable("value") String value) throws IOException {
        Map<String, Object> map = new HashMap<>();
        for (String str : value.split(",")) {
            String[] type = str.split(":");
            if (type.length == 2) {
                for (TD_SearchDictionary td_SearchDictionary : this.sds.getBaseMapper().selectList(
                        new LambdaQueryWrapper<TD_SearchDictionary>().eq(TD_SearchDictionary::getType, type[0]).eq(TD_SearchDictionary::getValue, type[1]))) {
                    map.put("tagId", td_SearchDictionary.getTagid());
                    map.put("valueString", td_SearchDictionary.getValue().split("-"));
                    map.put("flag", 1);
                }
            }
        }
        return R.ok().put("page", (Object) this.dPersontagService.tagSearch(map));
    }
}
